<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
   let arr1 = [1,3,5,6,5]
   let arr2 = [2,9,2,6,5]
    console.log(...arr1)

    let arr3 = [...arr1,...arr2]
    console.log(...arr3)


    //在函数中使用
    function sum(...numbers){
       console.log('@',numbers)
       return numbers.reduce((pre,value)=>{
        return pre+value
       })
    }
    console.log(sum(1,2,3,4,5,1))



    //构造字面量对象时使用展开语法
    let person = {name:'ton',age:18}

    let person2 = {...person}//复制对象

    // console.log(...person)报错不能展开对象

    person.name = 'jack'
    console.log(person2)
    console.log(person)

    //合并
    let person3 = {...person,name:'wangruike',address:"地球"}
    console.log(person3)

</script>
</html>